﻿using AutoMapper;
using Gridify.WebAPI.DTOs;
using Gridify.WebAPI.Models;

namespace Gridify.WebAPI.Profiles;

public class PersonMappingProfile : Profile
{
	public PersonMappingProfile()
	{
		CreateMap<Person, PersonDto>()
			.ForMember(dest => dest.FullName, opt => opt.MapFrom(src => $"{src.FirstName} {src.LastName}"))
			.ForMember(dest => dest.PhoneNumber, opt => opt.MapFrom(src => src.Contact.PhoneNumber))
			.ForMember(dest => dest.Address, opt => opt.MapFrom(src => src.Contact.Address))
			.ReverseMap();
	}
}
